<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>


<html>
<head>
	<c:import url="css.jsp"></c:import>    
</head>
<body>
<c:import url="header.jsp"></c:import>




<c:if test="${ fn:contains(requestScope['javax.servlet.forward.servlet_path'] , 'update')  }">
	
	${result}
	<br>
		<c:forEach items="${ loanPeriods}" var="loanPeriod">
	${ loanPeriod.periodId}
		${ loanPeriod.duration }  <a href="#" onclick="document.getElementById('${loanPeriod.periodId}').style.display='block'" >update</a> <br>
		
		<div id="${loanPeriod.periodId }" style="display:none">
		
				<form action="updateRenewal.do" method="post">
					<input type="hidden" name="loanPeriodId" value="${loanPeriod.periodId }" /> 
					<input value="${ loanPeriod.periodId}" disabled="disabled" /> 
					<input type="text" name="loanPeriodDuration" value="${loanPeriod.duration }" /> 
					<input type="submit" value="update" />

				</form>

			</div>
		
	</c:forEach>
	
	
</c:if>

<c:if test="${ fn:contains(requestScope['javax.servlet.forward.servlet_path'] , 'add')  }">

	
	<form action="addRenewal.do" method="post" >
		${error } <br>
		
		${result}<br/>
		Renewal Duration : <input name="loanPeriodDuration" /> </br>
		
		<input type="submit" value="add" />
	</form>
	
	<c:forEach items="${ loanPeriods}" var="loanPeriod">
	${ loanPeriod.periodId}
		${ loanPeriod.duration }   </br>
		
	</c:forEach>
	

	
	
	
</c:if>

<c:if test="${ fn:contains(requestScope['javax.servlet.forward.servlet_path'] , 'remove')  }">
	${result}
	
<table id="gradient-style" >
<thead>
<tr>
<th scope="col">Renewal ID</th>
<th scope="col">Renewal Duration</th>
</tr>
</thead>
<tbody>


<c:forEach items="${ loanPeriods}" var="loanPeriod" varStatus="status">
	<tr>
<td> ${ loanPeriod.periodId}</td>
<td>${ loanPeriod.duration }   </td>

</tr>

	

<td>
	<c:if test="${ status.last}"><a href="removeRenewal.do?id=${loanPeriod.periodId}">remove the last renewal </a></c:if>
	</c:forEach>
	
</c:if>
</td>
	</tbody>
</table>	

</body>
</html>